import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getx_learn/pages/list/index.dart' as ListPart;

class DetailView extends StatelessWidget {
  const DetailView({Key? key}) : super(key: key);

  _buildBackListTileRow(Map? val) {
    return (val == null || val.isEmpty)
        ? Container()
        : ListTile(
            title: Text("传值 id = " + val["id"].toString()),
            subtitle: Text('Get.back(result: {"success": true})'),
            onTap: () {
              Get.back(result: {"success": true});
            },
          );
  }

  @override
  Widget build(BuildContext context) {
    final details = Get.arguments == null ? null : Get.arguments as Map;
    final parameters = Get.parameters;

    return Scaffold(
      appBar: AppBar(
        title: const Text("详情"),
      ),
      body: ListView(
        children: [
          ListTile(
            title: Text("导航-返回"),
            subtitle: Text("Get.back()"),
            // onTap: () => {Get.offAll(ListPart.ListView())},
            onTap: () => {Get.back()},
          ),
          _buildBackListTileRow(details),
          _buildBackListTileRow(parameters),
        ],
      ),
    );
  }
}
